'use strict';

const Controller = require('egg').Controller;
const api = require('../../config/api');

class ResearchDetailController extends Controller {
  async index() {
    const { ctx } = this;
    // 处理请求参数：
    const id = ctx.request.query.id;
    // 获取新闻
    const res = await ctx.curl(`${api.basicUrl}/Research/getResearchItem`, {
      method: 'GET',
      contentType: 'json',
      dataType: 'json',
      data: {
        researchid: id,
      },
    });
    // 这里还需要获取研究种类
    const res_list = await ctx.curl(`${api.basicUrl}/Research/getResearchList`, {
      method: 'GET',
      contentType: 'json',
      dataType: 'json',
      data: {
        page: 1,
        pagesize: 10,
      },
    });
    console.log('res_list.data:', res_list.data);
    // ctx.logger.info(`ResearchDetailController, res: ${res.data.rows}`);
    await ctx.render('research_detail.html', { pageData: res.data, researchList: res_list.data });
  }
}

module.exports = ResearchDetailController;
